"""
图片转成素描风格
"""
import cv2

img = cv2.imread("images/chunxiao.png")

## 将照片灰度化处理
gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
## 将灰度化的照片反转处理
inverted_gray_image = 255 - gray_image
## 将反转的照片模糊化处理
blurred_inverted_gray_image = cv2.GaussianBlur(inverted_gray_image, (19, 19), 0)
## 再一次的进行反转
inverted_blurred_image = 255 - blurred_inverted_gray_image
### 颜色减淡混合处理
sketck = cv2.divide(gray_image, inverted_blurred_image, scale=256.0)
cv2.imwrite('images/chunxiao_sketch.jpg', sketck, [int(cv2.IMWRITE_JPEG_QUALITY), 95])
cv2.imshow("Original Image", img)
cv2.imshow("Pencil Sketch", sketck)
cv2.waitKey(0)
